<template>
  <aside class="config-panel">
    <div class="panel-section">
      <h3>📚 试卷配置</h3>
      
      <GradeSelector 
        v-model="config.grade" 
        @change="$emit('updateKnowledgePoints')"
      />
      
      <DifficultySelector v-model="config.difficulty" />
      
      <SubjectSelector 
        v-model="config.subject" 
        @change="$emit('updateKnowledgePoints')"
      />
      
      <KnowledgePointSelector 
        v-model="config.knowledgePoints"
        :subject="config.subject"
        :grade="config.grade"
      />
      
      <QuestionTypeSettings v-model="config.questionTypes" />

      <!-- 生成按钮 -->
      <div class="form-group">
        <button 
          class="btn-generate" 
          @click="$emit('generateExam')" 
          :disabled="!canGenerate || isGenerating"
        >
          {{ isGenerating ? '🔄 生成中...' : '✨ 生成试卷' }}
        </button>
      </div>
    </div>
  </aside>
</template>

<script>
import GradeSelector from './config/GradeSelector.vue'
import DifficultySelector from './config/DifficultySelector.vue'
import SubjectSelector from './config/SubjectSelector.vue'
import KnowledgePointSelector from './config/KnowledgePointSelector.vue'
import QuestionTypeSettings from './config/QuestionTypeSettings.vue'

export default {
  name: 'ExamConfigPanel',
  components: {
    GradeSelector,
    DifficultySelector,
    SubjectSelector,
    KnowledgePointSelector,
    QuestionTypeSettings
  },
  props: {
    config: {
      type: Object,
      required: true
    },
    canGenerate: {
      type: Boolean,
      default: false
    },
    isGenerating: {
      type: Boolean,
      default: false
    }
  },
  emits: ['updateKnowledgePoints', 'generateExam']
}
</script>

<style scoped>
.config-panel {
  flex: 0 0 400px;
  background: white;
  border-radius: 15px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  height: 100%;
  overflow-y: auto;
}

.panel-section h3 {
  color: #4a5568;
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.btn-generate {
  width: 100%;
  padding: 1rem 2rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}
</style>